<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Mantenimientos extends CI_Controller {

    public $tables = array();
    public $total_tables = array();

    function __construct() {
        parent::__construct();
        $this->load->language('crud_adm_' . $this->config->item('language'), $this->config->item('language'));
        $this->load->config('crud_config', true);
        $this->tables = $this->config->item('tables', 'crud_config');
        $this->config->load('database_tables');
        $this->total_tables = $this->config->item('dbtables');
        $this->load->library('Producto');
        $this->load->library('settings_crud');
        $this->load->library('GenerarMenu');
    }

    public function index() {
        if (!$this->ion_auth->logged_in()) {
            redirect('crud/login');
        } else {
            if ($this->ion_auth->is_admin()) {
                $this->load->view('index');
            } else {
                show_404();
            }
        }
    }

    public function blog_comment($idEntry = null) {
        if ($idEntry == null) {
            $this->blog_entry();
            return;
        }
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_blog_comment');
        $data['title_table'] = TITLES . lang('blog_comment');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['blog_comment']);
        $crud->set_subject($this->total_tables['blog_comment']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->where("fk_id_" . $this->total_tables['blog_entry'], $idEntry);
        $crud->set_relation('fk_id_'.$this->total_tables['blog_entry'], $this->total_tables['blog_entry'], 'entry_name');
        $crud->set_relation('fk_id_'.$this->total_tables['users'], $this->total_tables['users'], 'username');
        $crud->change_field_type('fk_id_' . $this->total_tables['users'], 'hidden', $this->ion_auth->user()->row()->id);
        $crud->change_field_type('fk_id_' . $this->total_tables['blog_entry'], 'hidden', $idEntry);
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function blog_entry() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_blog_entry');
        $data['title_table'] = TITLES . lang('blog_entry');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['blog_entry']);
        $crud->set_subject($this->total_tables['blog_entry']);
        $extras = array("fk_id_".$this->total_tables['blog_entry']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__, $extras));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__, $extras));
        $crud->set_relation('fk_id_' . $this->total_tables['users'], $this->total_tables['users'], 'username');
        $crud->set_relation_n_n('fk_id_'.$this->total_tables['blog_entry'], 'blog_entry_relationships__nn', 'blog_entry_category', 
                'fk_id_'.$this->total_tables['blog_entry'], 'fk_id_'.$this->total_tables['blog_entry_category'], 'category_name');
        $crud->callback_column('entry_name', array($this, '_nombre_callback'));
        $crud->change_field_type('entry_date', 'date');
        $crud->change_field_type('fk_id_' . $this->total_tables['users'], 'hidden', $this->ion_auth->user()->row()->id);
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    function _nombre_callback($value, $row) {
        return "<a href='" . site_url('crud/mantenimientos/' . $this->total_tables['blog_comment'] . '/' . $row->id) . "'>" . $value . "</a>";
    }

    public function blog_entry_category() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();

        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_blog_entry_category');
        $data['title_table'] = TITLES . lang('blog_entry_category');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['blog_entry_category']);
        $crud->set_subject($this->total_tables['blog_entry_category']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function caracteristica() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        //$this->load->language($this->total_tables['caracteristica'].'s_' . $this->config->item('language'), $this->config->item('language'));
        $this->load->model('admin_model');
        $this->load->helper('generacampos');
        $data['query'] = $this->admin_model->get_caracteristicas();
        $data['title'] = TITLES . lang('administrar_tablas');
        $data['title_table'] = TITLES . 'prueba_multinumero';

        $this->load->view('mantenimientos/caracteristica', $data);
    }

    public function comentario() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_comentario');
        $data['title_table'] = TITLES . lang('comentario');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['comentario']);
        $crud->set_subject($this->total_tables['comentario']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_'.$this->total_tables['producto'], $this->total_tables['producto'], 'descripcion');
        $crud->set_relation('fk_id_'.$this->total_tables['users'], $this->total_tables['users'], 'username');
        $crud->set_relation('fk2_id_'.$this->total_tables['users'], $this->total_tables['users'], 'username');
        $crud->set_relation('fk_id_'.$this->total_tables['empresa'], $this->total_tables['empresa'], 'nombre');
        if ($this->ion_auth->logged_in() && !$this->ion_auth->is_admin()) {
            $crud->unset_operations();
            $crud->unset_add();
        }
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function contenido() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->language('contenidos_'. $this->config->item('language'), $this->config->item('language'));
        $this->load->model('admin_model');
        $this->load->helper('generacampos');
        $data['query'] = $this->admin_model->get_contenidos();
        $data['title'] = TITLES . lang('administrar_tablas');
        $data['title_table'] = TITLES . 'prueba_multinumero';

        $this->load->view('mantenimientos/contenido', $data);
    }
    
    public function contenido_crud() {
        if(!$this->generarmenu->isMenuAccesible("contenido")) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_contenido');
        $data['title_table'] = TITLES . lang('contenido');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['contenido']);
        $crud->set_subject($this->total_tables['contenido']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_'.$this->total_tables['tipo_campo'], $this->total_tables['tipo_campo'], 'descripcion');
        $crud->set_relation('fk_id_'.$this->total_tables['contenido_tipo'], $this->total_tables['contenido_tipo'], 'nombre');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function contenido_tipo() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_contenido_tipo');
        $data['title_table'] = TITLES . lang('contenido_tipo');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['contenido_tipo']);
        $crud->set_subject($this->total_tables['contenido_tipo']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function distancia() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->language('caracteristicas_' . $this->config->item('language'), $this->config->item('language'));
        $this->load->model('admin_model');
        $this->load->helper('generacampos');
        $data['query'] = $this->admin_model->get_distancias();
        $data['title'] = TITLES . lang('administrar_tablas');
        $data['title_table'] = TITLES . 'prueba_multinumero';

        $this->load->view('mantenimientos/distancia', $data);
    }
    
    public function distancia_crud() {
        if(!$this->generarmenu->isMenuAccesible("distancia")) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_distancia');
        $data['title_table'] = TITLES . lang('distancia');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['distancia']);
        $crud->set_subject($this->total_tables['distancia']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_'.$this->total_tables['tipo_campo'], $this->total_tables['tipo_campo'], 'descripcion');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function distribucion() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->language('distribucion_'.$this->config->item('language'), $this->config->item('language'));
        $this->load->model('admin_model');
        $this->load->helper('generacampos');
        $data['query'] = $this->admin_model->get_distribucion();
        $data['title'] = TITLES . lang('administrar_tablas');
        $data['title_table'] = TITLES . 'prueba_multinumero';

        $this->load->view('mantenimientos/distribucion', $data);
    }
    
    public function distribucion_crud() {
        if(!$this->generarmenu->isMenuAccesible("distribucion")) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_distribucion');
        $data['title_table'] = TITLES . lang('distribucion');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['distribucion']);
        $crud->set_subject($this->total_tables['distribucion']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_'.$this->total_tables['tipo_campo'], $this->total_tables['tipo_campo'], 'descripcion');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function empresa() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_empresa');
        $data['title_table'] = TITLES . lang('empresa');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['empresa']);
        $crud->set_subject($this->total_tables['empresa']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function entorno() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_entorno');
        $data['title_table'] = TITLES . lang('entorno');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['entorno']);
        $crud->set_subject($this->total_tables['entorno']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function favorito() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_favorito');
        $data['title_table'] = TITLES . lang('favorito');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['favorito']);
        $crud->set_subject($this->total_tables['favorito']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_'.$this->total_tables['producto'], $this->total_tables['producto'], 'descripcion');
        $crud->set_relation('fk_id_'.$this->total_tables['users'], $this->total_tables['users'], 'username');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function fotos() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $ruta_parcial = 'assets/uploads/' . $this->ion_auth->user()->row()->company;
        $ruta_total = 'assets/uploads/' . $this->ion_auth->user()->row()->company . '/' . $this->session->userdata('product_id');
        
        $data['title'] = TITLES . lang('administrar_fotos');
        $data['title_table'] = TITLES . lang('fotos');

        if (!file_exists("./".$ruta_total)) {
            if (!file_exists("./".$ruta_parcial)) {
                mkdir("./".$ruta_parcial, 0777);
            }
            mkdir("./".$ruta_total, 0777);
        }
        
        $this->load->library('Image_CRUD');
        $image_crud = new Image_CRUD();
        $image_crud->set_primary_key_field('id');
        $image_crud->set_table('fotos')
                ->set_ordering_field('orden')
                ->set_image_path($ruta_total);
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $image_crud->render(), true);
        $this->load->view('plantillas/fotos', $data);
    }

    public function groups() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_groups');
        $data['title_table'] = TITLES . lang('groups');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['groups']);
        $crud->set_subject($this->total_tables['groups']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function mensaje() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_mensaje');
        $data['title_table'] = TITLES . lang('mensaje');
        $crud = new grocery_CRUD();
        $crud->set_table('mensaje');
        $crud->set_subject('mensaje');
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_users', 'users', 'username');
        $crud->set_relation('fk2_id_users', 'users', 'username');
        $crud->set_relation('fk_id_empresa', 'empresa', 'nombre');
        $crud->change_field_type('fk_id_' . $this->total_tables['empresa'], 'hidden', $this->ion_auth->user()->row()->company);
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function producto() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->producto_form(__FUNCTION__);
    }

    public function producto_tipo() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_producto_tipo');
        $data['title_table'] = TITLES . lang('producto_tipo');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['producto_tipo']);
        $crud->set_subject($this->total_tables['producto_tipo']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function promocion() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_promocion');
        $data['title_table'] = TITLES . lang('promocion');
        $crud = new grocery_CRUD();
        $crud->set_table($this->total_tables['promocion']);
        $crud->set_subject($this->total_tables['promocion']);
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->change_field_type('activo', 'true_false');
        $crud->set_field_upload('url_imagen', 'assets/promociones');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function reserva() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_reserva');
        $data['title_table'] = TITLES . lang('reserva');
        $crud = new grocery_CRUD();
        $crud->set_table('reserva');
        $crud->set_subject('reserva');
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_producto', 'producto', 'descripcion');
        $crud->set_relation('fk_id_empresa', 'empresa', 'nombre');
        $crud->change_field_type('id', 'integer');
        $crud->change_field_type('fecha_desde', 'date');
        $crud->change_field_type('fecha_hasta', 'date');
        $crud->change_field_type('fecmod', 'date');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function tarifa() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->language('calendar_' . $this->config->item('language'), $this->config->item('language'));
        $this->load->model('producto_model');
        $data['info_reservas'] = $this->producto_model->getReservasJson($this->session->userdata('product_id'));
        $data['info_tarifas'] = $this->producto_model->getTarifasJson($this->session->userdata('product_id'));
        $data['title'] = TITLES . lang('administrar_tarifa');
        $data['title_table'] = TITLES . lang('tarifa');
        $this->load->view('mantenimientos/tarifa', $data);
    }

    public function users() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_users');
        $data['title_table'] = TITLES . lang('users');
        $crud = new grocery_CRUD();
        $crud->set_table('users');
        $crud->set_subject('users');
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation_n_n('fk_users', 'caracteristica_usuario__nn', 'caracteristica', 'fk_id_users', 'fk_id_caracteristica', 'username');
        $crud->set_relation('fk_id_empresa', 'empresa', 'nombre');
        $crud->set_relation_n_n('fk_users', 'users_groups__nn', 'groups', 'fk_id_users', 'fk_id_groups', 'description');
        $crud->change_field_type('id', 'integer');
        $crud->change_field_type('ip_address', 'integer');
        $crud->change_field_type('created_on', 'integer');
        $crud->change_field_type('last_login', 'integer');
        $crud->change_field_type('idi_spanish', 'true_false');
        $crud->change_field_type('idi_english', 'true_false');
        $crud->change_field_type('idi_german', 'true_false');
        $crud->change_field_type('idi_italian', 'true_false');
        $crud->change_field_type('idi_french', 'true_false');
        $crud->change_field_type('idi_portuguese', 'true_false');
        $crud->change_field_type('idi_norwegian', 'true_false');
        $crud->change_field_type('idi_swedish', 'true_false');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }

    public function valoracion() {
        if(!$this->generarmenu->isMenuAccesible(__FUNCTION__)) show_404 ();
        if(!$this->product_in_session(__FUNCTION__)) return;
        $this->load->library('grocery_CRUD');
        $data['title'] = TITLES . lang('administrar_valoracion');
        $data['title_table'] = TITLES . lang('valoracion');
        $crud = new grocery_CRUD();
        $crud->set_table('valoracion');
        $crud->set_subject('valoracion');
        $crud->columns($this->settings_crud->get_columns_table(__FUNCTION__));
        $crud->fields($this->settings_crud->get_columns_form(__FUNCTION__));
        $crud->set_relation('fk_id_users', 'users', 'username');
        $crud->set_relation('fk_id_producto', 'producto', 'descripcion');
        $crud->set_relation('fk2_id_users', 'users', 'username');
        $crud->change_field_type('id', 'integer');
        $crud->change_field_type('puntuacion', 'integer');
        $crud->change_field_type('fecmod', 'date');
        $data['output_crud'] = $this->load->view('plantillas/contenedor_crud', $crud->render(), true);
        $this->load->view('plantillas/crud', $data);
    }
    
    public function product_in_session($redireccion = null){
	if($this->producto->count_all() == 0){
            $this->producto_form($redireccion, lang('mensaje_no_producto'));
            return false;
        }
        if($this->session->userdata('product_id') == ''){
            $this->producto_select($redireccion);
            return false;
        }else{
            return true;
        }
    }
    
    private function producto_form($redireccion = null, $mensaje = ''){
        $this->load->helper('generamtos');
        $this->load->language('producto_'.$this->config->item('language'), $this->config->item('language'));
        $data['redireccion_retorno'] = $redireccion;
        $data['fields'] = $this->settings_crud->get_columns_form($this->total_tables['producto']);
        $data['values'] = $this->settings_crud->get_values_form($this->total_tables['producto']);
        $data['output'] = $this->load->view('mantenimientos/producto', $data, 'true');
        $data['message'] = $mensaje;
        $data['title'] = TITLES.lang('title_wizard_producto');
        $this->load->view('plantillas/contenedor_wizard', $data);
    }

    private function producto_select($redireccion = null){
        $data['products'] = $this->producto->products();
        $data['redireccion_retorno'] = $redireccion;
        $data['output'] = $this->load->view('auxiliares/select_product', $data, 'true');
        $data['title'] = TITLES.lang('title_wizard_producto');
        $this->load->view('plantillas/contenedor_wizard', $data);
    }
}